package com.sh.shanhuo.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sh.shanhuo.R;
import com.sh.shanhuo.database.sort.SortInfoEntity;

import java.util.List;

public class WebTitleAdapter extends BaseQuickAdapter<SortInfoEntity, BaseViewHolder> {

    private final Context context;
    private int curPos;

    public WebTitleAdapter(Context context, List<SortInfoEntity> filterNames) {
        super(R.layout.titles_view, filterNames);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, SortInfoEntity item) {
        TextView filterName = helper.getView(R.id.title);
        ImageView choose = helper.getView(R.id.check_state);
        filterName.setText(item.sortName);
        if (helper.getAdapterPosition() == curPos) {
            filterName.setTextColor(context.getResources().getColor(R.color.item_check, null));
            choose.setVisibility(View.VISIBLE);
        } else {
            filterName.setTextColor(context.getResources().getColor(R.color.item_uncheck, null));
            choose.setVisibility(View.INVISIBLE);
        }
    }
    @SuppressLint("NotifyDataSetChanged")
    public void setCurPos(int curPos) {
        this.curPos = curPos;
        notifyDataSetChanged();
    }
}
